<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basepath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>员工管理</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <link href="<%=basepath%>css/index.css" rel="stylesheet" type="text/css">
    <link href="<%=basepath%>css/company.css" rel="stylesheet" type="text/css">
    <script src="<%=basepath%>js/jquery-1.8.3.min.js"></script>
    <script src="<%=basepath%>js/layer/layer.js"></script>
</head>
<body>
<div class="viewport">
    <div class="header">
       <div class="header-1">
           <a href="javascrpt:void(0)" id="join" class="header-2">
              <span id="account" class="account">${empty user.realName ? '' : user.realName}</span>&nbsp;&nbsp;<span id="deptName" class="deptName">${user.departmentName}</span>
           </a>
           <a href="/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=company&prefix=3g_company&entrance=yes" class="back" id="back">返回</a>
           <span class="span-num">WMP12300</span>
       </div>
    </div>
    <div class="content m-top">
        <div class="content-1">
            <div class="blank-1"></div>
            <div class="content-1-2">
                <span class="span-3"><b class="span-3-1">${user.companyName}</b></span>
            </div>
            <div class="blank-1"></div>
        </div>
        <div class="blank"></div>
        <c:forEach var="dp" items="${departs}">
        <c:if test="${dp.levelNum eq '2' and dp.type eq '1'}">
            <div class="blank"></div>
            <div class="company5-3">
                <div class="company5-3-1"><span class="span-1">${dp.sonDepart}</span></div>
            </div>
            <c:forEach var="els" items="${emplyees}">
                    <c:if test="${dp.departmentId eq els.departmentId}">
                        <div class="company5-4">
                                <a href="javascript:void(0)" class="company5-4-1">
                                    <table>
                                        <tr>
                                            <td class="td-v1">${els.departmentName}</td>
                                            <td class="td-v2">${els.realName}</td>
                                            <td class="td-v3">${els.atUserId}</td>
                                            <c:if test="${els.auditIsPassed eq '0'}">
                                                <td class="red td-v4"><span>未审核</span><input type="hidden" value="${dp.departmentId}"></td>
                                            </c:if>
                                            <c:if test="${els.auditIsPassed ne '0'}">
                                                <td class="gray td-v4"><span>已审核</span><input type="hidden" value="${dp.departmentId}"></td>
                                            </c:if>

                                        </tr>
                                    </table>
                                </a>
                            </div>
                    </c:if>
                </c:forEach>
            <div class="hr-1"></div>
            <c:forEach var="dp2" items="${departs}">
                <c:if test="${dp2.type eq '1' and dp2.fatherId eq dp.departmentId}">
                    <c:forEach var="emp" items="${emplyees}">
                        <c:if test="${dp2.departmentId eq emp.departmentId}">
                            <div class="company5-4">
                                <a href="javascript:void(0)" class="company5-4-1">
                                    <table>
                                        <tr>
                                            <td class="td-v1">${emp.departmentName}</td>
                                            <td class="td-v2">${emp.realName}</td>
                                            <td class="td-v3">${emp.atUserId}</td>
                                            <c:if test="${emp.auditIsPassed eq '0'}">
                                                <td class="red td-v4"><span>未审核</span><input type="hidden" value="${dp2.departmentId}"></td>
                                            </c:if>
                                            <c:if test="${emp.auditIsPassed ne '0'}">
                                                <td class="gray td-v4"><span>已审核</span><input type="hidden" value="${dp2.departmentId}"></td>
                                            </c:if>

                                        </tr>
                                    </table>
                                </a>
                            </div>
                        </c:if>
                    </c:forEach>
                </c:if>
            </c:forEach>
        </c:if>
    </c:forEach>
        <div class="blank"></div>
        <div class="space"></div>
    </div>
</div>
</body>
<script type="text/javascript">
    /*错误提示*/
    $(function(){
        var error = "${requestScope.returnMsg}";
        if(error != "" && error != "成功!"){
            layer.msg(error,{shadeClose:true,shade:0.1,time:2000});
        }
    });
    /*确认审核*/
    $(function(){
    	var check = "${user.departmentId}";
    	//alert(check)
    	if(check == "200603"){
    		$(".company5-4 .red").click(function(){
            	var zc = $(this).siblings(".td-v1").text();
            	var zc2 = $(this).siblings(".td-v2").text();
            	var zc3 = $(this).siblings(".td-v3").text();
            	var zc4 = $(this).children("input").val();
            	var zc5 = $(this).children("span").text();
            	//alert(zc+zc2+zc3+zc4)
                layer.confirm('是否审核？',{
                    icon: 3,
                    title:'审核'
                },function(sure){
                    layer.closeAll();
                    
                    location.reload()
                      $.ajax({
                        type:"post",
                        url:"/wape-web/api/core/centerService",
                        data:{
                            serviceCode:"MMZS133",
                            auditAtUserId:zc3,
                            departmentId:zc4
                        },
                        success:function(data){
                            var sure = eval("("+data+")");
                            if(sure.returnCode == "200"){
                                layer.msg("审核成功!",{shadeClose:true,shade:0.1,time:2000},function(){
                                	layer.closeAll();
                                	$(".company5-4 .red").children("span").text("已审核");
                                    $(".company5-4 .red").attr("class","gray td-v4");
                                    $(".company5-4 .gray").unbind("click");
                                	});
                            }
                            else{
                                layer.msg("审核失败!",{shadeClose:true,shade:0.1,time:2000},function(){
                                	layer.closeAll();
                                	});
                            }
                        }
                    });  

                });
            });
    	}
    	else if(check != "200603"){
    		$(".company5-4 .red").click(function(){
    			layer.msg("您无权限!",{shadeClose:true,shade:0.1,time:2000});
    		});
    	}
        
    });
</script>
</html>


